package com.csj.DesignPattern.singleton.demo3;

// 懒汉式
public class Singleton {

    private Singleton() {
    }
    private static Singleton instance;

    // 同步锁 保证线程安全
    // 读多写少，效率低
    public static synchronized Singleton getInstance() {
        //写少
        if (instance == null) {
            instance = new Singleton();
        }
        //读多
        return instance;
    }
}
